package com.wh.controller;

import com.wh.pojo.User;
import com.wh.service.UserService;
import com.wh.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/user/")
public class UserController {

    @Autowired
    private UserService userService;
    @PostMapping("login")
    public SysResult login(@RequestBody User user){
        String token = userService.findUserByUP(user);
        if (StringUtils.hasLength(token)){
            return SysResult.success(token);
        }else {
            return SysResult.fail();
        }
    }
}
